local thbattle__meidixin_youyuzhidu = fk.CreateSkill {

  name = "thbattle__meidixin_youyuzhidu",

  tags = {},

}



thbattle__meidixin_youyuzhidu:addEffect(fk.Damaged, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(thbattle__meidixin_youyuzhidu.name) and data.from
        and not player.dead
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, thbattle__meidixin_youyuzhidu.name,
      "#thbattle__meidixin_youyuzhidu:" .. target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_card = room:getNCards(1)[1]
    room:obtainCard(player, target_card, true, fk.ReasonPrey, player, thbattle__meidixin_youyuzhidu.name)
    player:showCards(target_card)
    if Fk:getCardById(target_card).suit ~= Card.Club then
      THB_Utility.addStatusMark(data.from, "@@thbattle__meidixin_youyuzhidu-turn")
    end
  end
})

thbattle__meidixin_youyuzhidu:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    if player:getMark("@@thbattle__meidixin_youyuzhidu-turn") > 0 then
      local subcards = card:isVirtual() and card.subcards or { card.id }
      return #subcards > 0 and
          table.every(subcards, function(id)
            return table.contains(player:getCardIds("h"), id)
          end)
    end
  end,
  prohibit_response = function(self, player, card)
    if player:getMark("@@thbattle__meidixin_youyuzhidu-turn") > 0 then
      local subcards = card:getEffectiveId() and { card:getEffectiveId() } or { card.id }
      return #subcards > 0 and
          table.every(subcards, function(id) return table.contains(player:getCardIds(Player.Hand), id) end)
    end
  end,
})

return thbattle__meidixin_youyuzhidu
